{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "随意玩玩，未经严格实盘测试"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "import OnePy as op\n",
    "from OnePy.custom_module.oanda_broker import OandaBroker\n",
    "from OnePy.custom_module.oanda_reader import OandaReader\n",
    "from OnePy.custom_module.oanda_recorder import OandaRecorder\n",
    "\n",
    "\n",
    "\n",
    "class SmaStrategy(op.StrategyBase):\n",
    "\n",
    "    def __init__(self):\n",
    "        super().__init__()\n",
    "\n",
    "    def handle_bar(self):\n",
    "        for ticker in self.env.tickers:\n",
    "            self.buy(100, ticker, takeprofit=15, stoploss=100)\n",
    "                \n",
    "TICKER_LIST = ['EUR_USD', \"USD_JPY\"]\n",
    "\n",
    "SLIPPAGE = dict(EUR_USD=1.5,\n",
    "                AUD_USD=1.5,\n",
    "                GBP_USD=2.0,\n",
    "                USD_CAD=2.0,\n",
    "                USD_JPY=1.5)\n",
    "\n",
    "for ticker in TICKER_LIST:\n",
    "    OandaReader(ticker=ticker, log=True)\n",
    "\n",
    "SmaStrategy()\n",
    "OandaBroker()\n",
    "OandaRecorder().set_setting(slippage=SLIPPAGE)\n",
    "\n",
    "go = op.OnePiece()\n",
    "go.show_log()\n",
    "go.set_forex_live_trading('S10')\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "+---------------------+\n",
      "|readers_1  |  EUR_USD|\n",
      "|readers_2  |  USD_JPY|\n",
      "+---------------------+\n",
      ">>>>>>>>>> Attention!! There is No cleaners!!! <<<<<<<<<<\n",
      "+--------------------------+\n",
      "|strategy_1  |  SmaStrategy|\n",
      "+--------------------------+\n",
      "+-------------------------+\n",
      "|brokers_1  |  OandaBroker|\n",
      "+-------------------------+\n",
      ">>>>>>>>>> Attention!! There is No risk_managers!!! <<<<<<<<<<\n",
      "+-----------------------------+\n",
      "|recorders_1  |  OandaRecorder|\n",
      "+-----------------------------+\n"
     ]
    }
   ],
   "source": [
    "go.output.show_setting()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "CRITICAL:OnePy:正在初始化OnePy\n",
      "CRITICAL:OnePy:=============== OnePy初始化成功！ ===============\n",
      "CRITICAL:OnePy:开始寻找OnePiece之旅~~~\n",
      "INFO:OnePy:2018-11-07 21:32:35, EUR_USD, Market Buy @ 1.14354, Created, size: 100\n",
      "INFO:OnePy:2018-11-07 21:32:35, EUR_USD, Stop Sell @ 0.14354, Created, size: 100\n",
      "INFO:OnePy:2018-11-07 21:32:35, EUR_USD, Limit Sell @ 1.29354, Created, size: 100\n",
      "INFO:OnePy:2018-11-07 21:32:35, USD_JPY, Market Buy @ 113.59500, Created, size: 100\n",
      "INFO:OnePy:2018-11-07 21:32:35, USD_JPY, Stop Sell @ 112.59500, Created, size: 100\n",
      "INFO:OnePy:2018-11-07 21:32:35, USD_JPY, Limit Sell @ 113.74500, Created, size: 100\n",
      "INFO:OnePy:2018-11-07 21:32:35, EUR_USD, Market Buy @ 1.14354, Submitted, size: 100\n",
      "INFO:OnePy:2018-11-07 21:32:35, USD_JPY, Market Buy @ 113.59500, Submitted, size: 100\n",
      "INFO:OnePy:2018-11-07 21:34:21, EUR_USD, Market Buy @ 1.14350, Created, size: 100\n",
      "INFO:OnePy:2018-11-07 21:34:21, EUR_USD, Stop Sell @ 0.14350, Created, size: 100\n",
      "INFO:OnePy:2018-11-07 21:34:21, EUR_USD, Limit Sell @ 1.29350, Created, size: 100\n",
      "INFO:OnePy:2018-11-07 21:34:21, USD_JPY, Market Buy @ 113.59200, Created, size: 100\n",
      "INFO:OnePy:2018-11-07 21:34:21, USD_JPY, Stop Sell @ 112.59200, Created, size: 100\n",
      "INFO:OnePy:2018-11-07 21:34:21, USD_JPY, Limit Sell @ 113.74200, Created, size: 100\n",
      "INFO:OnePy:2018-11-07 21:34:21, EUR_USD, Market Buy @ 1.14350, Submitted, size: 100\n",
      "INFO:OnePy:2018-11-07 21:34:21, USD_JPY, Market Buy @ 113.59200, Submitted, size: 100\n"
     ]
    }
   ],
   "source": [
    "go.sunny()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.1"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
